﻿using System.Data;
using l1cs.server.model.Instance;
using l1cs.server.utils;
using l1cs.server.model.skill;

namespace l1cs.server.model.trap
{
    class L1SkillTrap : L1Trap
    {
        private readonly int _skillId;
        private readonly int _skillTimeSeconds;

        public L1SkillTrap( DataRow item )
            : base( item )
        {
            _skillId = SqlUtils.toInt( item["skillId"] );
            _skillTimeSeconds = SqlUtils.toInt( item["skillTimeSeconds"] );
        }

        override public void onTrod( L1PcInstance trodFrom, L1Object trapObj )
        {
            sendEffect( trapObj );

            new L1SkillUse().handleCommands( trodFrom, _skillId, trodFrom.getId(),
                    trodFrom.getX(), trodFrom.getY(), null, _skillTimeSeconds,
                    L1SkillUse.TYPE_GMBUFF );
        }
    }
}
